<?php

  function save_buttons()
	{
  ?>
		<fieldset class="save_buttons">
    	<input type="submit" name="button" value="Save" />
  		<input type="reset" value="Cancel" onmouseup="location.href='index';" />
  		<input type="submit" name="button" value="Save and New" />
  		<input type="submit" name="button" value="Save and Close" />
		</fieldset>
  <?php
	}
	
	
	
	function singular($word)
  {
    // Here is the list of rules. To add a scenario,
    // Add the plural ending as the key and the singular
    // ending as the value for that key. This could be
    // turned into a preg_replace and probably will be
    // eventually, but for now, this is what it is.
    //
    // Note: The first rule has a value of false since
    // we don't want to mess with words that end with
    // double 's'. We normally wouldn't have to create
    // rules for words we don't want to mess with, but
    // the last rule (s) would catch double (ss) words
    // if we didn't stop before it got to that rule. 
    $rules = array( 
        'ss' => false, 
        'os' => 'o', 
  			'sses' => 'ss',
        'ies' => 'y', 
        'xes' => 'x', 
        'oes' => 'o', 
        'us' => 'i', 
        'ves' => 'f', 
  			'ice' => 'ouse',
        's' => '');
    // Loop through all the rules and do the replacement. 
    foreach(array_keys($rules) as $key){
        // If the end of the word doesn't match the key,
        // it's not a candidate for replacement. Move on
        // to the next plural ending. 
        if(substr($word, (strlen($key) * -1)) != $key) continue;
        // If the value of the key is false, stop looping
        // and return the original version of the word. 
        if($key === false) return $word;
        // We've made it this far, so we can do the
        // replacement. 
        return substr($word, 0, strlen($word) - strlen($key)) . $rules[$key]; 
    }
    return $word;
  }
	
	
	
	function success($str)
  {
  	$_SESSION['messages']['success'][] = $str;
  	return false;
  }
